package service;

import java.util.*;
import beans.*;
import db.*;

public class doctorService {
	public boolean login(String account,String password)
	{
		doctorDAO doctorDao=new doctorDAO();
		return doctorDao.valid(account, password);
	}
	
	public List<doctorBean> browse(){
		doctorDAO dao =new doctorDAO();
		return dao.getAllRecords();
	}
	
	public boolean adddoctor(doctorBean doctor)
	{
		doctorDAO doctorDao=new doctorDAO();
		return doctorDao.insertRecord(doctor);
	}
	
	public doctorBean getRecord(String doctorId)
	{
		doctorDAO doctorDao=new doctorDAO();
		return doctorDao.getRecord(doctorId);
	}
	
	public List<doctorBean> getdoctorsbyks(String ksid)
	{
		doctorDAO doctorDao=new doctorDAO();
		return doctorDao.getdoctorsbyks(ksid);
	}
	
	public int deldoctor(doctorBean doctor)
	{
		doctorDAO doctorDao=new doctorDAO();
		if(doctorDao.deleteRecord(doctor))
			return 1;
		else
			return 2;
	}
	
	public int updatedoctor(doctorBean beforeRecord,doctorBean afterRecord)
	{
		doctorDAO doctorDao=new doctorDAO();
		if(doctorDao.updateRecord(beforeRecord,afterRecord))
			return 1;
		else
			return 2;
	}
}
